﻿using Comm100.Framework.Domain.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using Bot.Domain.Bo;
using Castle.Windsor;
using Bot.Domain.Specifications;

namespace Bot.Domain.Categories.Service
{
    public class EnabledChannelDomainService : IEnabledChannelDomainService
    {
        private IWindsorContainer _container;
        private readonly IRepository<Guid, EnabledChannel> _repository;

        public EnabledChannelDomainService(IRepository<Guid, EnabledChannel> repository, IWindsorContainer container)
        {
            this._repository = repository;
            this._container = container;
        }

        public EnabledChannel Create(EnabledChannel category)
        {
            return _repository.Create(category);
        }

        public EnabledChannel Get(Guid id)
        {
            return _repository.Get(id);
        }

        public EnabledChannel Update(EnabledChannelUpdateBo bo)
        {
            EnabledChannel enabledChannel = _repository.Get(bo.Id);
            enabledChannel.Id = bo.Id;
            enabledChannel.BotId = bo.BotId;
            enabledChannel.Channel = bo.Channel;

            return enabledChannel;

        }

        public IEnumerable<EnabledChannel> List()
        {
            return _repository.ListAll();
        }

        public void Delete(Guid id)
        {
            EnabledChannel enabledChannel = _repository.Get(id);

            _repository.Delete(enabledChannel);

        }

        public IEnumerable<EnabledChannel> GetByBotId(Guid botId)
        {
            return _repository.List(new EnabledChannelFilterSpecification(botId));
        }
    }
}
